<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //记录sql日志
        if (config('app.env') != 'production') {
            \Log::info('============ URL: ' . request()->fullUrl() . ' ===============');
            \DB::listen(function ($query) {
                \Log::debug("[{$query->time}ms] " . str_replace_array('?', $query->bindings, $query->sql) . PHP_EOL);
            });
        }
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
